<?php
require_once(classdir.'commons.php');
require_once(classdir.'role.php');

class roles extends commons{
	var
		$tbl = 'roles';
	var
		$items = array();
		
	function get_items(){
		global $db;
		$this->items = array();
		$return = false;
		$sql = "
			SELECT
				id, name, slug, description
			FROM
				$this->tbl
		";
		$this->items = $db->query_assoc($sql,'slug');
		if (!empty($this->items)){
			foreach($this->items as $key=>$item){
				$this->items[$key] = new role($this->items[$key]);
			}
			$return = true;
		}
		return $return;
	}
	
	function get_role_id($role){
		$return = false;
		if (!empty($this->items) || $this->get_items()){
			$return = array_key_exists($role,$this->items);
		}
		return $return;
	}
}
?>